﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Shop.Core.ERP
{
    public static class ServiceCollectionExtension
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IServiceCollection AddERPServices(this IServiceCollection services, IConfiguration configuration)
        {
            var data = configuration.Get<ERPOptions>();
            services.Configure<ERPOptions>(options => { options.AppKey = data.AppKey; options.AppSecret = data.AppSecret; options.ShopId = data.ShopId; });
            services.AddSingleton<IERPProvider, ERPProvider>();
            return services;
        }
    }
}
